package com.example.materialviewpagerdemo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateInt
{
    public static int timeLengthJudge(String smalldate,String bigdate) throws ParseException
    {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        Calendar cal = Calendar.getInstance();
        cal.setTime(sdf.parse(smalldate));
        long time1 = cal.getTimeInMillis();
        cal.setTime(sdf.parse(bigdate));
        long time2 = cal.getTimeInMillis();
        long between_days=(time2-time1)/(1000*3600*24);
        int timeLength= Integer.parseInt(String.valueOf(between_days));
        return timeLength;
    }

    public static boolean judgeStartTime(String startDate) throws ParseException
    {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        Date date = new SimpleDateFormat("yyyy-MM-dd").parse(startDate);
        Calendar now = Calendar.getInstance();
        now.setTime(date);

        int year = now.get(Calendar.YEAR);
        int month = now.get(Calendar.MONTH) + 1; // 0-based!
        int day = now.get(Calendar.DAY_OF_MONTH);

        if (year>2016||year==2016&&month>8||year==2016&&month==8&&day>23)
            return true;
        else {
            return false;
        }
    }
}
